<%@page import="com.crm.entity.Opportunity,com.crm.entity.Supplier,java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/temp.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<script src="<%=application.getContextPath()%>/js/jquery-1.6.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<!-- InstanceEndEditable -->
<link href="../css/css-crm.css" rel="stylesheet" type="text/css" />

<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<script type="text/javascript" src="<%=application.getContextPath()%>/js/jquery-1.6.min.js"></script>	
</head>

<body>
<%List<Opportunity> opprtlist =(List<Opportunity>)request.getAttribute("opprtunity");%>
<div id="main">
   <%@include file="common/header.jsp" %>
  <%@include file="common/submenu.jsp" %>
  <div id="content">
   <div id="resultMsg"  align="center" class="result_msg">
    <% 
   String msg= request.getParameter("msgsrc");
    String curref= request.getParameter("currentref");
    System.out.println("the current frefrence is"+curref);
   
    	if(msg!=null){
    		System.out.println(msg);
    		out.println(msg);
    	}
    	
    %>
    </div>
    <div id="enqclient" style="display: none;" align="center" class="result_msg">

    </div>
    <form id="exform" name="frm1" action="<%=application.getContextPath()%>/exportsource/save.do"   method="post" onsubmit="javascript:openWindow();">
    <div id="work-area2">
      <div class="heading2">Export To Source </div>
	  
      <div class="boxIFS" id="mainDiv">
     
     
      <table width="100%" border="0" style="height:80px;"  cellspacing="0" cellpadding="0">
          <tr>
            <td width="500" align="left" valign="middle">
            <table width="500" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="right"  width=40%" valign="middle">Reference Number </td>
                <td align="center" width="50%" valign="top">
                <select name="reflist"  id="reflistid"  class="form_select" id="reflist"  >
                
                 <option value="">Select Reference</option>
         <% 
              if(opprtlist!=null){
            	  System.out.println("the size of the pr list is "+opprtlist.size());
	      	for(int i=0;i<opprtlist.size();i++){
	      	%>
           <option  <%if(curref!=null && curref.equals(opprtlist.get(i).getRefNum())){ %>selected="selected" <%} %>  value="<%=opprtlist.get(i).getRefNum()%>"><%=opprtlist.get(i).getRefNum()%></option>
                   	<%	}
	              	}%>
                </select></td>
              </tr>
        </table></td>
         
              <td width="300" align="left" valign="middle">
            <table width="300" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="left" valign="middle"> <input type="button" id="getsrcid" class="buttonleft"  value="Get Sources"/></td>
                <td align="left" valign="middle"></td>
              </tr>
            </table></td>
          </tr>
        </table>   
      </div>

	  <div id="ajaxLoader" style="display:none" align="center"><img src="<%=application.getContextPath()%>/images/ajax_loader.gif"/></div> 
    <table style="height:300px; width:910px;" ><tr><td>
	   <div class="boxtable" id="partsDiv">
	  </div>
	  </td></tr></table>
    </div>

     </form>

  </div><div id="footer"></div>  
</div>
</body>
</html>
<script> 

$("#getsrcid").click(function(){


	var refid=$("#reflistid").val();
	
		if(refid==null || refid==""){
			 jAlert("Please Select Reference Number");
			 return false;
		 }
	else{
		$("#ajaxLoader").show();
	$.ajax({
		url:"<%=application.getContextPath()%>/exportsource/search.do" ,
	  	data:"refno="+refid,
	  	success:function(res){
	  		$('#partsDiv').html(res);
			
	  	}
	  }).done(function(html){
			$("#ajaxLoader").hide();
		}).fail(function(html){
			$("#ajaxLoader").hide();
			alert("Failed To Load the Data");
		});
	}
});
$(function(){
	var refid=$("#reflistid").val();
		if(refid==null || refid==""){
			 //jAlert("Please Select Reference Number");
			 return false;
		 }
	else{
		$("#ajaxLoader").show();
	$.ajax({
		url:"<%=application.getContextPath()%>/exportsource/search.do" ,
	  	data:"refno="+refid,
	  	success:function(res){
	  		$('#partsDiv').html(res);
			
	  	}
	  }).done(function(html){
			$("#ajaxLoader").hide();
		}).fail(function(html){
			$("#ajaxLoader").hide();
			alert("Failed To Load the Data");
		});
	}
});
 
</script>


